﻿using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zhp.Common.WebApp;
using Zhp.SqlSugar.UnitOfWork;
using Zhp.Workflow.Entity.DataOptions;
using Zhp.Workflow.Models;

namespace Zhp.Workflow.Activities.DataOptions
{
    public class ApproverDataProvider : IApproverDataProvider
    {
        private readonly ISqlSugarClient _dbContext;
        public ApproverDataProvider(IUnitOfWork<SugarUnitOfWork> unitOfWork)
        {
            _dbContext = unitOfWork.Db;
        }

        public async Task<List<ComboSelectItem>> GetApproverUsers()
        {
            return await _dbContext.Queryable<SysUser>().Where(x => x.UserName != "root").Select(x => new ComboSelectItem { IsEnabled = x.IsEnabled, Name = x.UserName, Value = x.Id.ToString(), Text = x.NickName }).ToListAsync();
        }

        public async Task<List<ComboSelectItem>> GetApproverRoles()
        {
            return await _dbContext.Queryable<SysRole>().Select(x => new ComboSelectItem { IsEnabled = x.IsEnabled, Value = x.Id.ToString(), Text = x.RoleName }).ToListAsync();
        }
    }

}
